/* 
 * File:   compile_assert.h
 * Author: gustavo
 *
 * Created on June 27, 2012, 7:58 PM
 */

#ifndef COMPILE_ASSERT_HPP
#define	COMPILE_ASSERT_HPP


// A template and a specialization

template<bool> struct StaticCheck {
	StaticCheck(...);
};

template<> struct StaticCheck < false > {
};


#define CONCAT( a, b ) CONCAT_INTERNAL( a, b )
#define CONCAT_INTERNAL( a, b )	a##b

// The macro (generates a local class)
#define STATIC_CHECK(expr, msg) {					\
	class CONCAT(ERROR___##msg, __LINE__) {};		\
	sizeof(											\
			(										\
				StaticCheck<expr>( CONCAT(ERROR___##msg, __LINE__)() )\
			)										\
	);												\
}

#define STATIC_ASSERT( expr ) STATIC_CHECK( expr, ASSERTION__)

#endif	/* COMPILE_ASSERT_HPP */

